package com.miaoji.controller;

import com.miaoji.domain.po.ClothCategory;
import com.miaoji.domain.po.Color;
import com.miaoji.domain.po.Size;
import com.miaoji.mapper.ColorMapper;
import com.miaoji.mapper.SizeMapper;
import com.miaoji.service.ClothCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    SizeMapper sizeMapper;
    @Autowired
    ColorMapper colorMapper;
    @Autowired
    ClothCategoryService categoryService;
    @GetMapping("/size")
    public List SizeSelect(){
        List<Size> results = sizeMapper.select();
        return results;
    }

    @GetMapping("/color")
    public List ColorSelect(){
        List<Color> results = colorMapper.select();
        return results;
    }
    @GetMapping("/select")
    public  ClothCategory categorySelect(@RequestBody int cloth_id){
        return categoryService.categorySelect(cloth_id);
    }
    @PostMapping("/insert")
    public boolean categoryInsert(@RequestBody ClothCategory category){
        boolean b = categoryService.categoryInsert(category);
        return b;
    }
    @PostMapping("/update")
    public boolean categoryUpdate(@RequestBody ClothCategory clothCategory){
        boolean b = categoryService.categoryUpdate(clothCategory);
        return b;
    }
}
